package com.zlx.sharelive.activity;

import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.zlx.module_base.base_ac.BaseAc;
import com.zlx.module_base.base_api.res_data.HistoryBean;
import com.zlx.module_base.base_api.util.ApiUtil;
import com.zlx.module_base.base_util.SPUtil;
import com.zlx.module_network.api1.livedata.BaseObserver;
import com.zlx.module_network.api1.livedata.BaseObserverCallBack;
import com.zlx.module_network.bean.ApiResponse;
import com.zlx.sharelive.R;
import com.zlx.sharelive.adapter.CommonRecyclerViewAdapter;
import com.zlx.sharelive.adapter.CommonRecyclerViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 充值明细
 */
public class RechargeDetailsAc extends BaseAc {

    @BindView(R.id.rv_data)
    RecyclerView rv_data;
    @BindView(R.id.tv_title)
    TextView tv_title;

    private int page = 1;
    private List<HistoryBean> mList = new ArrayList<>();
    private CommonRecyclerViewAdapter<HistoryBean> mAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.ac_withdrawal_details;
    }

    @Override
    public void initViews() {
        super.initViews();

        tv_title.setText("充值明细");

        chargeHistory(page);
        initRecyclerView();
    }

    /**
     * 提现明细
     */
    private void chargeHistory(int page) {
        ApiUtil.getMoneyApi().chargeHistory(SPUtil.getToken(RechargeDetailsAc.this), String.valueOf(page)).
                observe(this, new BaseObserver<>(new BaseObserverCallBack<ApiResponse<HistoryBean>>() {
                    @Override
                    public void onSuccess(ApiResponse<HistoryBean> data) {
                        if (null != data) {
                            if (null != data.getData()) {

                            }
                        }
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();

                    }
                }));
    }


    /**
     * 初始化数据
     */
    private void initRecyclerView() {
        rv_data.setLayoutManager(new LinearLayoutManager(this));

        mAdapter = new CommonRecyclerViewAdapter<HistoryBean>(this, mList) {
            @Override
            public void convert(CommonRecyclerViewHolder holder, HistoryBean entity, int position) {

            }

            @Override
            public int getLayoutViewId(int viewType) {
                return R.layout.item_withdrawal_details;
            }
        };

        rv_data.setAdapter(mAdapter);

    }

    @OnClick(R.id.iv_back)
    public void setOnClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }
}
